<?php
$xtpl = new XTemplate("modules/home/left_panel_cate.htm");
//--
//--
//--
$waypathlink = '&raquo;&nbsp;<a class="waypath">Left panel Menu</a>';
$xtpl_main->assign("waypathlink",$waypathlink);
//--
$add_button = $GUI->button_ren("New","javascript: add('?mod=home&act=left_panel_cate_task');");
$xtpl->assign("add_button",$add_button);
//--
$update_button = $GUI->button_ren("Update","javascript: update('UPDATE', document.frmAddleftPanel);");
$xtpl->assign("update_button",$update_button);
//--
$delete_button = $GUI->button_ren("Delete","javascript: del('DELETE', document.frmAddleftPanel);");
$xtpl->assign("delete_button",$delete_button);
//--
//--
//--
//--
//--
//--
$rs = $DB->ZenDataList('admin_cate','',"parent_id='67' OR (parent_id='110' AND cate_act='left_sub')",'cate_sort','');
$no=1;
while($row = mysql_fetch_array($rs)){
	$row[no]=$no++;	
	if($no%2!=0)
		$row['class'] = "row1";
	else 
		$row['class'] = "row2";
	//--
	$row[edit_link] = '?mod=home&act=left_panel_cate_task&id='.$row[cate_id].'';
	// check_link here
	$sql_link = "SELECT * FROM {$DP}admin_cate WHERE parent_id=".$row[cate_id]." ORDER BY cate_sort ASC";
	$check_count = mysql_num_rows($DB->SQLexec($sql_link));
	/*
	if($check_count > 0){
		$row[linkcate]= '?mod=home&amp;act='.$row[cate_act].'&amp;cid='.$row['cate_id'].'';
		$row[content_link] = '?mod=home&act=left_panel_cate_content&id='.$row[cate_id].'';
	}
	else{
		$row[linkcate]= '?mod=home&amp;act=left_sub&amp;cid='.$row['cate_id'].'';
	    $row[content_link] = '?mod=home&amp;act=left_content&amp;cid='.$row['cate_id'].'';
	}
	*/
	$row[content_link] = '?mod=home&act=left_panel_cate_content&id='.$row[cate_id].'';
	$row[linkcate]= '?mod=home&amp;act=left_sub&amp;cid='.$row['cate_id'].'';
	//--
	$xtpl->assign("list",$row);
	$xtpl->parse("center.list");
}
//--
//--
//--
//--
//--
//--
if($_POST['type'] == "DELETE"){
	$checked_delete = $_POST[checked_delete];
	for ($i=0;$i<count($checked_delete);$i++) {
		$delete_list.= $checked_delete[$i].",";
	}
	if($delete_list){
		$delete_list = substr($delete_list,0,strlen($delete_list)-1);
		$delete_split=split(",",$delete_list);
		for($i=0;$i<count($delete_split);$i++){
			$sql_ = "DELETE FROM {$DP}admin_cate WHERE cate_id='{$delete_split[$i]}'";
			mysql_query($sql_);
		}
	}
	$GUI->redir('?mod=home&act=left_panel_cate');
}
//--
//--
//--
//--
//--
//--
if($_POST['type']=="UPDATE"){
	$chkid = $_POST[chkid];
	$cate_sort = $_POST[cate_sort];
	if(count($chkid) > 0){
		$id = '('.implode(",",$chkid).')';
		foreach($cate_sort as $id=>$value){
			$sql = "UPDATE {$DP}admin_cate SET cate_sort={$value} WHERE cate_id={$id}";
			mysql_query($sql);
		}
	}
	$GUI->redir('?mod=home&act=left_panel_cate');
}
?>